//
//  PointTurnViewController.m
//  AllFamily
//
//  Created by chirui on 2018/6/6.
//  Copyright © 2018年 Shui. All rights reserved.
//

#import "PointTurnViewController.h"

@interface PointTurnViewController ()
@property (weak, nonatomic) IBOutlet UITextField *pointText;
@property (weak, nonatomic) IBOutlet UITextField *userText;
@property (weak, nonatomic) IBOutlet UILabel *pointLabel;

@end

@implementation PointTurnViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    TitleView(@"积分转账");
    self.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithIcon:@"icon_nav_renter" target:self action:@selector(backBtnClick)];
    
    _pointLabel.text = [NSString stringWithFormat:@"可用积分 %@",self.pointStr];
}

-(void)backBtnClick{
    
    [self.navigationController popViewControllerAnimated:YES];
}


- (IBAction)sureBtnClick:(id)sender {
    
    if (_pointText.text.length<=0) {
        
        SHuiMBhudTextTimeStr(@"请输入转账积分");
    }else if (_userText.text.length<=0){
        
        SHuiMBhudTextTimeStr(@"请输入转账账户");
    }else {
        
        [self scroreRequest];
    }
    
}

-(void)scroreRequest{
    
    NSDictionary * dic = @{@"mid":USER_DEFAULTGet(@"mid"),
                           @"token":USER_DEFAULTGet(@"token"),
                           @"phone":_userText.text,
                           @"score":_pointText.text
                           };
    
    [PostNetWorking postNetWorkingStr:RequestUrlStr(scoreTransfer_api) andparameters:dic Success:^(id responseObject) {
        
        if (codeSucess) {
            
            SHuiMBhudTextTimeStr(@"提交成功");
            dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
                
                [self.navigationController popViewControllerAnimated:YES];
            });
        }else {
            
            SHuiMBhudTextTimeStr(responseObject[@"mark"]);
        }
        
    } failed:^(NSError *error) {
        
        SHuiMBhudTextNetError;
    }];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
